Steps to Write a Program

Writing an assembly language program requires a systematic approach to ensure correctness and efficiency. Here are the essential steps to follow when developing a program for the 8085 microprocessor:

🔍

Analyze the Problem

Understand the requirements and constraints of the problem you need to solve

🧠

Develop Program Logic

Determine the sequence of operations needed to solve the problem

📝

Write an Algorithm

Create a step-by-step procedure that outlines the solution

🔄

Make a Flowchart

Visualize the algorithm with a flowchart to better understand the program flow

💻

Write Program Instructions

Convert the algorithm into assembly language instructions for the 8085

Example Program

📋Problem Statement

Program 8085 in Assembly language to add two 8-bit numbers and store 8-bit result in register C.

📝Algorithm

  1. Get two numbers
    • Load 1st no. in register D
    • Load 2nd no. in register E
  2. Add them
    • Copy register D to A
    • Add register E to A
  3. Store result
    • Copy A to register C
  4. Stop
    • Stop processing

Flowchart

Start
⬇️
Load first number in register D
⬇️
Load second number in register E
⬇️
Copy register D to accumulator A
⬇️
Add register E to accumulator A
⬇️
Copy accumulator A to register C
⬇️
Stop

💻Assembly Language Program

1
MVI D, 05H; Load first number (05H) in register D
2
MVI E, 03H; Load second number (03H) in register E
3
MOV A, D; Copy register D to accumulator A
4
ADD E; Add register E to accumulator A
5
MOV C, A; Copy accumulator A to register C
6
HLT; Halt the program

Addressing Modes of 8085

The Intel 8085 microprocessor supports several addressing modes that determine how operands are accessed during instruction execution. These addressing modes offer flexibility in programming and allow efficient use of memory and register resources.

📋Instruction Format

The general format of an 8085 assembly language instruction is:

1
[Label:] Mnemonic [Operands] [;comments]

Examples:

1
HLT
2
MVI A, 20H
3
MOV M, A;Copy A to memory location whose address is stored in register pair HL
4
LOAD: LDA 2050H;Load A with contents of memory location with address 2050H
5
READ: IN 07H;Read data from Input port with address 07H

🔢Types of Addressing Modes

Immediate Addressing

In immediate addressing, the operand is specified directly within the instruction itself.

MVI A, 05H; Load immediate data 05H into the accumulator
📍

Direct Addressing

In direct addressing, the operand's memory address is directly specified within the instruction.

LDA 2050H; Load accumulator with contents of memory location 2050H
📝

Register Addressing

In register addressing, the operand is located in one of the microprocessor's registers.

MOV B, C; Move the contents of register C into register B
🔍

Indirect Addressing

In indirect addressing, the operand's address is stored in a register or memory location, and the data is accessed indirectly.

MOV A, M; Move the data from memory location addressed by HL into the accumulator
📊

Register Indirect Addressing

This is a specific form of indirect addressing where the operand's address is stored in a register.

LDAX B; Load accumulator with data from memory location in BC register pair
📈

Indexed Addressing

In indexed addressing, the operand's address is calculated by adding an index value to a base address. The 8085 doesn't have built-in support for indexed addressing, but it can be simulated using other addressing modes.

These addressing modes provide versatility in accessing operands and data, allowing programmers to write efficient and compact code for various tasks. Mastery of addressing modes is essential for effective programming on the Intel 8085 microprocessor, enabling the utilization of its capabilities to their fullest extent.

Instruction & Data Formats

In the Intel 8085 microprocessor architecture, instructions and data are structured according to specific formats to facilitate their interpretation and execution. The instruction format typically consists of an operation code (opcode) and, in some cases, additional operands.


Instructions are encoded using a variable-length format, with opcodes representing different operations such as data transfer, arithmetic, logical, branching, and control transfer instructions. Each opcode is associated with a specific operation that the microprocessor performs when executing the instruction. Additionally, some instructions may require additional data, which can be specified as immediate values, memory addresses, or register operands, depending on the addressing mode used.

💾Data Representation

Data in the 8085 architecture can be represented in various formats, including binary, hexadecimal, and ASCII. Binary data consists of sequences of 1s and 0s, which are interpreted by the microprocessor as numerical values or instructions. Hexadecimal notation is commonly used to represent binary data in a more compact and readable format, with each hexadecimal digit representing four bits of binary data. ASCII encoding is used for representing alphanumeric characters and symbols, with each character assigned a unique binary code.

Both instructions and data are stored in the memory of the 8085 microprocessor, with instructions typically residing in program memory and data stored in either program memory or data memory locations. The microprocessor fetches instructions from memory using the program counter (PC) and executes them sequentially, interpreting each opcode and its associated operands according to the instruction set architecture.

Instruction Size Classification

8085 Instruction set can be classified according to size (in bytes) as:

  1. 1-byte Instructions
  2. 2-byte Instructions
  3. 3-byte Instructions

1️⃣One-byte Instructions

One-byte instructions in the Intel 8085 microprocessor architecture are compact instructions that occupy only one byte of memory. These instructions typically represent simple operations that can be executed quickly by the microprocessor.


One-byte instructions are often used for basic arithmetic, logical operations, data transfer between registers, and control transfer instructions such as NOP (no operation) and HLT (halt). Since they are encoded in only one byte, they are easy to decode and execute, contributing to faster program execution and efficient memory utilization.


Examples of one-byte instructions in the 8085 architecture include:

1
MOV r1, r2; Move the contents of register r2 into register r1
2
ADD r; Add the contents of register r to the accumulator
3
SUB r; Subtract the contents of register r from the accumulator
4
INR r; Increment the contents of register r
5
NOP; Perform no operation
6
HLT; Halt the microprocessor

2️⃣Two-byte Instructions

Two-byte instructions in the Intel 8085 microprocessor architecture are instructions that require two bytes of memory to represent. These instructions are typically more complex than one-byte instructions and may involve additional operands or data. Two-byte instructions provide more functionality and flexibility, allowing for a wider range of operations to be performed by the microprocessor.


Some examples of two-byte instructions in the 8085 architecture include:

1
MVI Rd, data; Move immediate data (data) into the specified register (Rd)
2
Example: MVI A, 0AH; Move immediate value 0AH into the accumulator
3
LXI Rp, data; Load immediate data (data) into the specified register pair (Rp)
4
Example: LXI H, 2050H; Load immediate value 2050H into the HL register pair
5
STA address; Store the contents of the accumulator into the memory location specified by the 16-bit address
6
Example: STA 3000H; Store the contents of the accumulator into memory location 3000H

3️⃣Three-byte Instructions

In the Intel 8085 microprocessor architecture, three-byte instructions are instructions that require three bytes of memory to represent. These instructions are typically more complex and involve additional operands or data compared to one-byte or two-byte instructions. Three-byte instructions provide even greater functionality and flexibility, enabling a wider range of operations to be performed.


Some examples of three-byte instructions in the 8085 architecture include:

1
LHLD address; Load the HL register pair with the contents of the memory location specified by the 16-bit address
2
Example: LHLD 2000H; Load the HL register pair with the contents of memory location 2000H
3
SHLD address; Store the contents of the HL register pair into the memory location specified by the 16-bit address
4
Example: SHLD 3000H; Store the contents of the HL register pair into memory location 3000H
5
LXI Rp, address; Load immediate 16-bit data (address) into the specified register pair (Rp)
6
Example: LXI SP, 4000H; Load immediate value 4000H into the stack pointer register pair

Block Data Transfer

Block data transfer involves moving a block of data from one memory location to another. This is a common operation in assembly programming, especially when dealing with arrays or large data sets. The following program demonstrates how to transfer a block of data from one memory location to another using the 8085 microprocessor.

💻Assembly Program for Block Data Transfer

1
MVI C, 0AH; Initialize counter i.e no. of bytes. Store the count in Register C, ie ten
2
LXI H, 2200H; Initialize source memory pointer. Data Starts from 2200 location
3
LXI D, 2300H; Initialize destination memory pointer
4
BK: MOV A, M; Get byte from source memory block i.e 2200 to accumulator
5
STAX D; Store byte in the destination memory block i.e 2300 as stored in D-E pair
6
INX H; Increment source memory pointer
7
INX D; Increment destination memory pointer
8
DCR C; Decrement counter to keep track of bytes moved
9
JNZ BK; If counter not zero repeat steps
10
HLT; Terminate program

Summary

This unit explores assembly language programming based on Intel 8085, focusing on basic tasks like data transfer, arithmetic operations, and shifts. It progresses to more intricate programs, demonstrating the use of loops and comparisons for code conversion, character coding, and finding the largest value in an array.

Assembly language programs are machine-dependent and require a deep understanding of underlying hardware architecture. Development in assembly language often demands more effort and expertise, potentially increasing development time and costs.

The assembler is a crucial component of computer design, enabling smooth communication between memory modules and the central processing unit (CPU). It handles the tedious operation of converting symbolic code into object code, which can be stored as paper tape or diskette files using the Intellect development system's text editor.

Memory interfacing is essential for ensuring smooth data communication between the CPU and memory, and memory interface strategies must change to provide larger capacities, quicker speeds, and new memory modules as memory technology grows.

In summary, understanding the programming model and its functions is crucial for effectively using the microprocessor's capabilities and creating assembly language programs. The Intel 8085 microprocessor architecture consists of the Program Counter (PC), a 16-bit register that stores the memory address of subsequent instructions. It automatically increases after each instruction execution, allowing the CPU to execute instructions sequentially until a branch or jump instruction modifies the value.

The Stack Pointer (SP) Register oversees the stack memory region, following the Last-of-First-Out (LIFO) principle. The instruction set of the 8085 microprocessor includes data transfer, arithmetic, logical, branching, and control transfer instructions. The 8085 assembly language allows for problem analysis, program logic development, algorithm creation, and program instruction writing.

The microprocessor supports several addressing modes, allowing for flexibility in programming and efficient use of memory and register resources. Instructions and data are structured according to specific formats, with instructions encoding in variable-length format and data represented in binary, hexadecimal, and ASCII formats. The 8085 instruction set can be classified as 1-byte Instructions, 2-byte Instructions, and 3-byte Instructions. Assembly language defines instructions, while memory interfacing is used for efficient memory utilization.